package org.keyword;

/**
 * @version v1.0.0
 * 创建时间：2022/6/28 09:25
 */
public class VolatileTest {
    // double check
    private volatile static VolatileTest object;
    private VolatileTest(){}
    public static VolatileTest getObject() {
        if (object==null){
            synchronized (VolatileTest.class){
                if (object==null){
                    object = new VolatileTest();
                    return object;
                }
            }
        }
        return object;
    }

    public static void main(String[] args) {
        VolatileTest.getObject();
    }
}
